package com.mianle.userapi.util;

import java.math.BigDecimal;

public class CalculationUtils {

    /**
     * 计算订单预计免单金额
     * @param totalProfit 总让利额 * 2.5
     * @return
     */
    public static  BigDecimal orderFreeMoney(BigDecimal totalProfit){
        return BigNum.multiply(totalProfit,new BigDecimal("2.5"));
    }

    /**
     * 计算订单全免需补差价
     * @param totalMoney 订单总金额
     * @param totalProfit 订单总让利金额
     * @return
     */
    public static  BigDecimal userAddProfit(BigDecimal totalMoney,BigDecimal totalProfit){
        if (totalProfit.compareTo(BigDecimal.ZERO)==0){
           //总让利额为0则不参与免单
            return BigDecimal.ZERO;
        }
        BigDecimal allFreeProfitMoney = BigNum.multiply(totalMoney, new BigDecimal("0.4"));
        return BigNum.subtract(allFreeProfitMoney,totalProfit);
    }

    /**
     * 计算订单应付总金额
     * @param totalMoney 总金额
     * @param shippingFee 运费
     * @param userAddProfit 全免补差价
     * @return
     */
    public static BigDecimal allOrderMoney(BigDecimal totalMoney,BigDecimal shippingFee,BigDecimal userAddProfit){
         return BigNum.add(totalMoney,BigNum.add(shippingFee,userAddProfit));
    }

}
